const BASE_URL = 'http://localhost:3005'

export function fetch(url: string, obj: any) {
  return new Promise(async resolve => {
    const {data} = await useFetch(url, {
      method: obj.method ?? 'GET',
      query: obj.query ?? undefined,
      params: obj.params ?? undefined,
      body: obj.body ?? undefined,
      headers: obj.headers ?? undefined,
      baseURL: BASE_URL
    })

    resolve(data.value)
  })
}
